home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.direct.ca!usenet
- From: etoivane@direct.ca (Ed Toivanen)
- Newsgroups: comp.lang.c
- Subject: Re: How to check array lenght?
- Date: 25 Feb 1996 21:47:02 GMT
- Organization: Your Organization
- Message-ID: <4gqlcm$jno@aphex.direct.ca>
- References: <4gbphl$ht@malakor.kku.ac.th>
- NNTP-Posting-Host: 204.174.243.150
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.6
-
- In article <4gbphl$ht@malakor.kku.ac.th>, terdthai@kku1.kku.ac.th says...
- >
- >In subroutine that recieve pointer of array.
- >How to check number of multidimention array in that routine?
-
- You can't there is no standard way to check the size of a non zero-terminated
- array. You have to pass the size of the array along with the array.
- Personally, I encapsulate the array along with its current size in a struct:
-
- typedef tagarray{
- DATA* array;
- int size=MAX_SIZE;
- }ARRAY;
-
- /*blah, blah, blah*/
- ARRAY anArray[MAX_SIZE];
-
- func(anArray);
-
- /*blah, blah, blah*/
- void func(ARRAY * ary);
- if(func->int > MAXSIZE){
- /*do some cool stuff*/
- }
-
- Thats it
- Ed
-
-